﻿using B.S.BasicData.Api.Read.Application.Command.ShenPi;
using B.S.BasicData.Api.Read.DTO;
using B.S.BasicData.Domian.Entities.shenpi;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class shenpiController : ControllerBase
    {
        private readonly IMediator mediator;

        public shenpiController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ShenpiGetDTO>> ShenpiGet([FromQuery]ShenpiGetCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<int>> ShenpiDel([FromQuery] ShenpiDelCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> ShenpiCreate(ShenpiCreateCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> ShenpiUpdate( ShenpiUpdateCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询部门
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<DeptModel>>> DeptGet([FromQuery]DeptGetCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<int>> ShenPiState([FromQuery] ShenPiStateCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public Task<ApiPaging<ApprovalDTO>> GetApproval([FromQuery]GetApprovalCommand request)
        {
            //异常处理
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        
    }
}
